/*  BEGIN_FILE_HDR
******************************************Copyright(C)*****************************************
*
*                                       YKXH  Technology
*
***********************************File Info***************************************************
*   File Name       @: App_Dtc.h
************************************************************************************************
*   Project/Product @: 
*   Title           @: 
*   Author          @: 
************************************************************************************************
*   Description     @: 
*
************************************************************************************************
*   Limitations     @: 
*
************************************************************************************************
*
************************************************************************************************
*   Revision History:
* 
*    Version    Date          Initials       CR#             Descriptions
*   ---------   ----------    -------------  ----------    ---------------
*   1.0         2012/04/03   zhongliang.yang   N/A            Original 
*   1.1         xxxx/xx/xx      xxxxx         N/A            xxxxxxxx 
*     
************************************************************************************************
* END_FILE_HDR*/


#ifndef APP_DTC_H_
#define APP_DTC_H_


#ifdef  APP_DTC_C
#define APP_DTC_EXT
#define APP_DTC_CON
#else
#define APP_DTC_EXT extern
#define APP_DTC_CON const
#endif
#include "../src/BSW/CommS/NM/YKBase/BaseComm.h"
//#include "App_Dcm.h"
#include "../src/BSW/CommS/NM/UDS/Dcm/App_Dcm.h"
#define DTC_COLLECT_NUM                           NUM_OF_DTC       /* cfg DTC num */
#define SNAPSHOT_RECORD_NUM                       1U               /* number of Snapshot Record */
#define EXTENDED_DATA_RECORD_NUM                  2U               /* number of Snapshot Record */


/********Timer Cfg**************/

#define DTC_MOCYCLE_VAILD_TIME                    (uint8)1U  /* one cycle vaild will record DTC */
#define DTC_CLEAR_CYCLE_CFG                       (uint8)40U /* DTC will be auto cleared if this DTC doesn't happen in 40 monitoring cycles */

#define DTC_TEST_FAILTIMES_CFG                    (uint8) 0U
#define DTC_CONFIRMTIMES_CFG                      (uint16)1U


typedef struct
{
	uint16   DtcRecordDID            ;
	uint8    DtcRecordDIDSize           ;
	uint8    DTCRecordInfoLength     ;	
}DTCRecordInfoCfgType;



/**************************************************************************************************
* Global variables for client
**************************************************************************************************/

extern uint8  gMoCycleValidFlag ;
extern uint8  gDiagActiveFlag ;

/**************************************************************************************************
* DTC Fault detect times cfg
**************************************************************************************************/
extern const uint16 DTC_ConfirmTimes_Config[DTC_COLLECT_NUM] ;
extern const uint8  DTC_AgingCnt_Config[DTC_COLLECT_NUM] ;
extern const sint8  DTC_TestFailTimes_Config[DTC_COLLECT_NUM] ;

extern DTCRecordInfoCfgType DTC_SnapShot_Config[SNAPSHOT_RECORD_NUM];
#if (reportDTCExtendedDataRecordByDTCNumber == STD_ON)
extern DTCRecordInfoCfgType DTC_ExtendedData_Config[EXTENDED_DATA_RECORD_NUM];
#endif

/**************************************************************************************************
* Global variables
**************************************************************************************************/
//extern uint8* SnapShot[DTC_COLLECT_NUM][SNAPSHOT_RECORD_NUM];
extern uint8* ExtendedData[DTC_COLLECT_NUM][EXTENDED_DATA_RECORD_NUM];

extern uint8  DTC_AgingCnt[DTC_COLLECT_NUM];

/**************************************************************************************************
* Global Function Implementation
**************************************************************************************************/
extern void   App_DTC_Init(void);
extern void   DTCMoCycle_Proc(void);
extern void   DTC_AgingCntActive(void);
extern void   DTC_OccurCnt_Record(void);
extern void   DTC_TaskUpdate(void);

#if (reportDTCSnapshotRecordByDTCNumber == STD_ON)
extern void   DTC_SnapshotRecord(void);
extern void   DTC_SnapshotClear(void);
extern uint8  DTC_GetSnapShot(uint8 *pData,uint8 idxDtc,uint8 idxSnap);
#endif
#if (reportDTCExtendedDataRecordByDTCNumber == STD_ON)
extern void   DTC_ExtendedDataRecord(void);
extern void   DTC_ExtendedDataClear(void);
#endif

#endif /* DTC_USERCDE_H_ */
